<template>
  <view>
    <map id="map" class="map" :latitude="latitude" :longitude="longitude" :markers="markers"></map>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        latitude: "",
        longitude: "",
        markers: [{
          id: 1,
          latitude: "",
          longitude: "",
          iconPath: "",
          width: "30",
          height: "30"
        }]
      };
    },
    onLoad() {
      var that = this;
      uni.getLocation({
        type: 'gcj02',
        success(res) {
          console.log('当前位置的经度：' + res.longitude);
          console.log('当前位置的纬度：' + res.latitude);
          that.latitude = res.latitude;
          that.longitude = res.longitude;
          that.markers[0].longitude = that.longitude;
          that.markers[0].latitude = that.latitude;
          console.log(that.$data);
        }
      })
    }
  }
</script>

<style lang="scss">
  .map {
    width: 100%;
    height: 500rpx;
  }
</style>